package com.room.search.web.rest;

import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.hasItem;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;

import com.room.search.IntegrationTest;
import com.room.search.domain.RoomUserBrokerChatList;
import com.room.search.repository.RoomUserBrokerChatListRepository;
import com.room.search.service.dto.RoomUserBrokerChatListDTO;
import com.room.search.service.mapper.RoomUserBrokerChatListMapper;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.List;
import java.util.Random;
import java.util.concurrent.atomic.AtomicLong;
import javax.persistence.EntityManager;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.http.MediaType;
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.transaction.annotation.Transactional;

/**
 * Integration tests for the {@link RoomUserBrokerChatListResource} REST controller.
 */
@IntegrationTest
@AutoConfigureMockMvc
@WithMockUser
class RoomUserBrokerChatListResourceIT {

    private static final Long DEFAULT_FRIEND_USER_ID = 1L;
    private static final Long UPDATED_FRIEND_USER_ID = 2L;

    private static final Long DEFAULT_USER_ID = 1L;
    private static final Long UPDATED_USER_ID = 2L;

    private static final String DEFAULT_CREATED_BY = "AAAAAAAAAA";
    private static final String UPDATED_CREATED_BY = "BBBBBBBBBB";

    private static final Instant DEFAULT_CREATED_DATE = Instant.ofEpochMilli(0L);
    private static final Instant UPDATED_CREATED_DATE = Instant.now().truncatedTo(ChronoUnit.MILLIS);

    private static final String DEFAULT_LAST_MODIFIED_BY = "AAAAAAAAAA";
    private static final String UPDATED_LAST_MODIFIED_BY = "BBBBBBBBBB";

    private static final Instant DEFAULT_LAST_MODIFIED_DATE = Instant.ofEpochMilli(0L);
    private static final Instant UPDATED_LAST_MODIFIED_DATE = Instant.now().truncatedTo(ChronoUnit.MILLIS);

    private static final String ENTITY_API_URL = "/api/room-user-broker-chat-lists";
    private static final String ENTITY_API_URL_ID = ENTITY_API_URL + "/{id}";

    private static Random random = new Random();
    private static AtomicLong count = new AtomicLong(random.nextInt() + (2 * Integer.MAX_VALUE));

    @Autowired
    private RoomUserBrokerChatListRepository roomUserBrokerChatListRepository;

    @Autowired
    private RoomUserBrokerChatListMapper roomUserBrokerChatListMapper;

    @Autowired
    private EntityManager em;

    @Autowired
    private MockMvc restRoomUserBrokerChatListMockMvc;

    private RoomUserBrokerChatList roomUserBrokerChatList;

    /**
     * Create an entity for this test.
     *
     * This is a static method, as tests for other entities might also need it,
     * if they test an entity which requires the current entity.
     */
    public static RoomUserBrokerChatList createEntity(EntityManager em) {
        RoomUserBrokerChatList roomUserBrokerChatList = new RoomUserBrokerChatList()
            .friendUserId(DEFAULT_FRIEND_USER_ID)
            .userId(DEFAULT_USER_ID)
            .createdBy(DEFAULT_CREATED_BY)
            .createdDate(DEFAULT_CREATED_DATE)
            .lastModifiedBy(DEFAULT_LAST_MODIFIED_BY)
            .lastModifiedDate(DEFAULT_LAST_MODIFIED_DATE);
        return roomUserBrokerChatList;
    }

    /**
     * Create an updated entity for this test.
     *
     * This is a static method, as tests for other entities might also need it,
     * if they test an entity which requires the current entity.
     */
    public static RoomUserBrokerChatList createUpdatedEntity(EntityManager em) {
        RoomUserBrokerChatList roomUserBrokerChatList = new RoomUserBrokerChatList()
            .friendUserId(UPDATED_FRIEND_USER_ID)
            .userId(UPDATED_USER_ID)
            .createdBy(UPDATED_CREATED_BY)
            .createdDate(UPDATED_CREATED_DATE)
            .lastModifiedBy(UPDATED_LAST_MODIFIED_BY)
            .lastModifiedDate(UPDATED_LAST_MODIFIED_DATE);
        return roomUserBrokerChatList;
    }

    @BeforeEach
    public void initTest() {
        roomUserBrokerChatList = createEntity(em);
    }

    @Test
    @Transactional
    void createRoomUserBrokerChatList() throws Exception {
        int databaseSizeBeforeCreate = roomUserBrokerChatListRepository.findAll().size();
        // Create the RoomUserBrokerChatList
        RoomUserBrokerChatListDTO roomUserBrokerChatListDTO = roomUserBrokerChatListMapper.toDto(roomUserBrokerChatList);
        restRoomUserBrokerChatListMockMvc
            .perform(
                post(ENTITY_API_URL)
                    .contentType(MediaType.APPLICATION_JSON)
                    .content(TestUtil.convertObjectToJsonBytes(roomUserBrokerChatListDTO))
            )
            .andExpect(status().isCreated());

        // Validate the RoomUserBrokerChatList in the database
        List<RoomUserBrokerChatList> roomUserBrokerChatListList = roomUserBrokerChatListRepository.findAll();
        assertThat(roomUserBrokerChatListList).hasSize(databaseSizeBeforeCreate + 1);
        RoomUserBrokerChatList testRoomUserBrokerChatList = roomUserBrokerChatListList.get(roomUserBrokerChatListList.size() - 1);
        assertThat(testRoomUserBrokerChatList.getFriendUserId()).isEqualTo(DEFAULT_FRIEND_USER_ID);
        assertThat(testRoomUserBrokerChatList.getUserId()).isEqualTo(DEFAULT_USER_ID);
        assertThat(testRoomUserBrokerChatList.getCreatedBy()).isEqualTo(DEFAULT_CREATED_BY);
        assertThat(testRoomUserBrokerChatList.getCreatedDate()).isEqualTo(DEFAULT_CREATED_DATE);
        assertThat(testRoomUserBrokerChatList.getLastModifiedBy()).isEqualTo(DEFAULT_LAST_MODIFIED_BY);
        assertThat(testRoomUserBrokerChatList.getLastModifiedDate()).isEqualTo(DEFAULT_LAST_MODIFIED_DATE);
    }

    @Test
    @Transactional
    void createRoomUserBrokerChatListWithExistingId() throws Exception {
        // Create the RoomUserBrokerChatList with an existing ID
        roomUserBrokerChatList.setId(1L);
        RoomUserBrokerChatListDTO roomUserBrokerChatListDTO = roomUserBrokerChatListMapper.toDto(roomUserBrokerChatList);

        int databaseSizeBeforeCreate = roomUserBrokerChatListRepository.findAll().size();

        // An entity with an existing ID cannot be created, so this API call must fail
        restRoomUserBrokerChatListMockMvc
            .perform(
                post(ENTITY_API_URL)
                    .contentType(MediaType.APPLICATION_JSON)
                    .content(TestUtil.convertObjectToJsonBytes(roomUserBrokerChatListDTO))
            )
            .andExpect(status().isBadRequest());

        // Validate the RoomUserBrokerChatList in the database
        List<RoomUserBrokerChatList> roomUserBrokerChatListList = roomUserBrokerChatListRepository.findAll();
        assertThat(roomUserBrokerChatListList).hasSize(databaseSizeBeforeCreate);
    }

    @Test
    @Transactional
    void getAllRoomUserBrokerChatLists() throws Exception {
        // Initialize the database
        roomUserBrokerChatListRepository.saveAndFlush(roomUserBrokerChatList);

        // Get all the roomUserBrokerChatListList
        restRoomUserBrokerChatListMockMvc
            .perform(get(ENTITY_API_URL + "?sort=id,desc"))
            .andExpect(status().isOk())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
            .andExpect(jsonPath("$.[*].id").value(hasItem(roomUserBrokerChatList.getId().intValue())))
            .andExpect(jsonPath("$.[*].friendUserId").value(hasItem(DEFAULT_FRIEND_USER_ID.intValue())))
            .andExpect(jsonPath("$.[*].userId").value(hasItem(DEFAULT_USER_ID.intValue())))
            .andExpect(jsonPath("$.[*].createdBy").value(hasItem(DEFAULT_CREATED_BY)))
            .andExpect(jsonPath("$.[*].createdDate").value(hasItem(DEFAULT_CREATED_DATE.toString())))
            .andExpect(jsonPath("$.[*].lastModifiedBy").value(hasItem(DEFAULT_LAST_MODIFIED_BY)))
            .andExpect(jsonPath("$.[*].lastModifiedDate").value(hasItem(DEFAULT_LAST_MODIFIED_DATE.toString())));
    }

    @Test
    @Transactional
    void getRoomUserBrokerChatList() throws Exception {
        // Initialize the database
        roomUserBrokerChatListRepository.saveAndFlush(roomUserBrokerChatList);

        // Get the roomUserBrokerChatList
        restRoomUserBrokerChatListMockMvc
            .perform(get(ENTITY_API_URL_ID, roomUserBrokerChatList.getId()))
            .andExpect(status().isOk())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
            .andExpect(jsonPath("$.id").value(roomUserBrokerChatList.getId().intValue()))
            .andExpect(jsonPath("$.friendUserId").value(DEFAULT_FRIEND_USER_ID.intValue()))
            .andExpect(jsonPath("$.userId").value(DEFAULT_USER_ID.intValue()))
            .andExpect(jsonPath("$.createdBy").value(DEFAULT_CREATED_BY))
            .andExpect(jsonPath("$.createdDate").value(DEFAULT_CREATED_DATE.toString()))
            .andExpect(jsonPath("$.lastModifiedBy").value(DEFAULT_LAST_MODIFIED_BY))
            .andExpect(jsonPath("$.lastModifiedDate").value(DEFAULT_LAST_MODIFIED_DATE.toString()));
    }

    @Test
    @Transactional
    void getNonExistingRoomUserBrokerChatList() throws Exception {
        // Get the roomUserBrokerChatList
        restRoomUserBrokerChatListMockMvc.perform(get(ENTITY_API_URL_ID, Long.MAX_VALUE)).andExpect(status().isNotFound());
    }

    @Test
    @Transactional
    void putNewRoomUserBrokerChatList() throws Exception {
        // Initialize the database
        roomUserBrokerChatListRepository.saveAndFlush(roomUserBrokerChatList);

        int databaseSizeBeforeUpdate = roomUserBrokerChatListRepository.findAll().size();

        // Update the roomUserBrokerChatList
        RoomUserBrokerChatList updatedRoomUserBrokerChatList = roomUserBrokerChatListRepository
            .findById(roomUserBrokerChatList.getId())
            .get();
        // Disconnect from session so that the updates on updatedRoomUserBrokerChatList are not directly saved in db
        em.detach(updatedRoomUserBrokerChatList);
        updatedRoomUserBrokerChatList
            .friendUserId(UPDATED_FRIEND_USER_ID)
            .userId(UPDATED_USER_ID)
            .createdBy(UPDATED_CREATED_BY)
            .createdDate(UPDATED_CREATED_DATE)
            .lastModifiedBy(UPDATED_LAST_MODIFIED_BY)
            .lastModifiedDate(UPDATED_LAST_MODIFIED_DATE);
        RoomUserBrokerChatListDTO roomUserBrokerChatListDTO = roomUserBrokerChatListMapper.toDto(updatedRoomUserBrokerChatList);

        restRoomUserBrokerChatListMockMvc
            .perform(
                put(ENTITY_API_URL_ID, roomUserBrokerChatListDTO.getId())
                    .contentType(MediaType.APPLICATION_JSON)
                    .content(TestUtil.convertObjectToJsonBytes(roomUserBrokerChatListDTO))
            )
            .andExpect(status().isOk());

        // Validate the RoomUserBrokerChatList in the database
        List<RoomUserBrokerChatList> roomUserBrokerChatListList = roomUserBrokerChatListRepository.findAll();
        assertThat(roomUserBrokerChatListList).hasSize(databaseSizeBeforeUpdate);
        RoomUserBrokerChatList testRoomUserBrokerChatList = roomUserBrokerChatListList.get(roomUserBrokerChatListList.size() - 1);
        assertThat(testRoomUserBrokerChatList.getFriendUserId()).isEqualTo(UPDATED_FRIEND_USER_ID);
        assertThat(testRoomUserBrokerChatList.getUserId()).isEqualTo(UPDATED_USER_ID);
        assertThat(testRoomUserBrokerChatList.getCreatedBy()).isEqualTo(UPDATED_CREATED_BY);
        assertThat(testRoomUserBrokerChatList.getCreatedDate()).isEqualTo(UPDATED_CREATED_DATE);
        assertThat(testRoomUserBrokerChatList.getLastModifiedBy()).isEqualTo(UPDATED_LAST_MODIFIED_BY);
        assertThat(testRoomUserBrokerChatList.getLastModifiedDate()).isEqualTo(UPDATED_LAST_MODIFIED_DATE);
    }

    @Test
    @Transactional
    void putNonExistingRoomUserBrokerChatList() throws Exception {
        int databaseSizeBeforeUpdate = roomUserBrokerChatListRepository.findAll().size();
        roomUserBrokerChatList.setId(count.incrementAndGet());

        // Create the RoomUserBrokerChatList
        RoomUserBrokerChatListDTO roomUserBrokerChatListDTO = roomUserBrokerChatListMapper.toDto(roomUserBrokerChatList);

        // If the entity doesn't have an ID, it will throw BadRequestAlertException
        restRoomUserBrokerChatListMockMvc
            .perform(
                put(ENTITY_API_URL_ID, roomUserBrokerChatListDTO.getId())
                    .contentType(MediaType.APPLICATION_JSON)
                    .content(TestUtil.convertObjectToJsonBytes(roomUserBrokerChatListDTO))
            )
            .andExpect(status().isBadRequest());

        // Validate the RoomUserBrokerChatList in the database
        List<RoomUserBrokerChatList> roomUserBrokerChatListList = roomUserBrokerChatListRepository.findAll();
        assertThat(roomUserBrokerChatListList).hasSize(databaseSizeBeforeUpdate);
    }

    @Test
    @Transactional
    void putWithIdMismatchRoomUserBrokerChatList() throws Exception {
        int databaseSizeBeforeUpdate = roomUserBrokerChatListRepository.findAll().size();
        roomUserBrokerChatList.setId(count.incrementAndGet());

        // Create the RoomUserBrokerChatList
        RoomUserBrokerChatListDTO roomUserBrokerChatListDTO = roomUserBrokerChatListMapper.toDto(roomUserBrokerChatList);

        // If url ID doesn't match entity ID, it will throw BadRequestAlertException
        restRoomUserBrokerChatListMockMvc
            .perform(
                put(ENTITY_API_URL_ID, count.incrementAndGet())
                    .contentType(MediaType.APPLICATION_JSON)
                    .content(TestUtil.convertObjectToJsonBytes(roomUserBrokerChatListDTO))
            )
            .andExpect(status().isBadRequest());

        // Validate the RoomUserBrokerChatList in the database
        List<RoomUserBrokerChatList> roomUserBrokerChatListList = roomUserBrokerChatListRepository.findAll();
        assertThat(roomUserBrokerChatListList).hasSize(databaseSizeBeforeUpdate);
    }

    @Test
    @Transactional
    void putWithMissingIdPathParamRoomUserBrokerChatList() throws Exception {
        int databaseSizeBeforeUpdate = roomUserBrokerChatListRepository.findAll().size();
        roomUserBrokerChatList.setId(count.incrementAndGet());

        // Create the RoomUserBrokerChatList
        RoomUserBrokerChatListDTO roomUserBrokerChatListDTO = roomUserBrokerChatListMapper.toDto(roomUserBrokerChatList);

        // If url ID doesn't match entity ID, it will throw BadRequestAlertException
        restRoomUserBrokerChatListMockMvc
            .perform(
                put(ENTITY_API_URL)
                    .contentType(MediaType.APPLICATION_JSON)
                    .content(TestUtil.convertObjectToJsonBytes(roomUserBrokerChatListDTO))
            )
            .andExpect(status().isMethodNotAllowed());

        // Validate the RoomUserBrokerChatList in the database
        List<RoomUserBrokerChatList> roomUserBrokerChatListList = roomUserBrokerChatListRepository.findAll();
        assertThat(roomUserBrokerChatListList).hasSize(databaseSizeBeforeUpdate);
    }

    @Test
    @Transactional
    void partialUpdateRoomUserBrokerChatListWithPatch() throws Exception {
        // Initialize the database
        roomUserBrokerChatListRepository.saveAndFlush(roomUserBrokerChatList);

        int databaseSizeBeforeUpdate = roomUserBrokerChatListRepository.findAll().size();

        // Update the roomUserBrokerChatList using partial update
        RoomUserBrokerChatList partialUpdatedRoomUserBrokerChatList = new RoomUserBrokerChatList();
        partialUpdatedRoomUserBrokerChatList.setId(roomUserBrokerChatList.getId());

        partialUpdatedRoomUserBrokerChatList
            .friendUserId(UPDATED_FRIEND_USER_ID)
            .createdDate(UPDATED_CREATED_DATE)
            .lastModifiedBy(UPDATED_LAST_MODIFIED_BY)
            .lastModifiedDate(UPDATED_LAST_MODIFIED_DATE);

        restRoomUserBrokerChatListMockMvc
            .perform(
                patch(ENTITY_API_URL_ID, partialUpdatedRoomUserBrokerChatList.getId())
                    .contentType("application/merge-patch+json")
                    .content(TestUtil.convertObjectToJsonBytes(partialUpdatedRoomUserBrokerChatList))
            )
            .andExpect(status().isOk());

        // Validate the RoomUserBrokerChatList in the database
        List<RoomUserBrokerChatList> roomUserBrokerChatListList = roomUserBrokerChatListRepository.findAll();
        assertThat(roomUserBrokerChatListList).hasSize(databaseSizeBeforeUpdate);
        RoomUserBrokerChatList testRoomUserBrokerChatList = roomUserBrokerChatListList.get(roomUserBrokerChatListList.size() - 1);
        assertThat(testRoomUserBrokerChatList.getFriendUserId()).isEqualTo(UPDATED_FRIEND_USER_ID);
        assertThat(testRoomUserBrokerChatList.getUserId()).isEqualTo(DEFAULT_USER_ID);
        assertThat(testRoomUserBrokerChatList.getCreatedBy()).isEqualTo(DEFAULT_CREATED_BY);
        assertThat(testRoomUserBrokerChatList.getCreatedDate()).isEqualTo(UPDATED_CREATED_DATE);
        assertThat(testRoomUserBrokerChatList.getLastModifiedBy()).isEqualTo(UPDATED_LAST_MODIFIED_BY);
        assertThat(testRoomUserBrokerChatList.getLastModifiedDate()).isEqualTo(UPDATED_LAST_MODIFIED_DATE);
    }

    @Test
    @Transactional
    void fullUpdateRoomUserBrokerChatListWithPatch() throws Exception {
        // Initialize the database
        roomUserBrokerChatListRepository.saveAndFlush(roomUserBrokerChatList);

        int databaseSizeBeforeUpdate = roomUserBrokerChatListRepository.findAll().size();

        // Update the roomUserBrokerChatList using partial update
        RoomUserBrokerChatList partialUpdatedRoomUserBrokerChatList = new RoomUserBrokerChatList();
        partialUpdatedRoomUserBrokerChatList.setId(roomUserBrokerChatList.getId());

        partialUpdatedRoomUserBrokerChatList
            .friendUserId(UPDATED_FRIEND_USER_ID)
            .userId(UPDATED_USER_ID)
            .createdBy(UPDATED_CREATED_BY)
            .createdDate(UPDATED_CREATED_DATE)
            .lastModifiedBy(UPDATED_LAST_MODIFIED_BY)
            .lastModifiedDate(UPDATED_LAST_MODIFIED_DATE);

        restRoomUserBrokerChatListMockMvc
            .perform(
                patch(ENTITY_API_URL_ID, partialUpdatedRoomUserBrokerChatList.getId())
                    .contentType("application/merge-patch+json")
                    .content(TestUtil.convertObjectToJsonBytes(partialUpdatedRoomUserBrokerChatList))
            )
            .andExpect(status().isOk());

        // Validate the RoomUserBrokerChatList in the database
        List<RoomUserBrokerChatList> roomUserBrokerChatListList = roomUserBrokerChatListRepository.findAll();
        assertThat(roomUserBrokerChatListList).hasSize(databaseSizeBeforeUpdate);
        RoomUserBrokerChatList testRoomUserBrokerChatList = roomUserBrokerChatListList.get(roomUserBrokerChatListList.size() - 1);
        assertThat(testRoomUserBrokerChatList.getFriendUserId()).isEqualTo(UPDATED_FRIEND_USER_ID);
        assertThat(testRoomUserBrokerChatList.getUserId()).isEqualTo(UPDATED_USER_ID);
        assertThat(testRoomUserBrokerChatList.getCreatedBy()).isEqualTo(UPDATED_CREATED_BY);
        assertThat(testRoomUserBrokerChatList.getCreatedDate()).isEqualTo(UPDATED_CREATED_DATE);
        assertThat(testRoomUserBrokerChatList.getLastModifiedBy()).isEqualTo(UPDATED_LAST_MODIFIED_BY);
        assertThat(testRoomUserBrokerChatList.getLastModifiedDate()).isEqualTo(UPDATED_LAST_MODIFIED_DATE);
    }

    @Test
    @Transactional
    void patchNonExistingRoomUserBrokerChatList() throws Exception {
        int databaseSizeBeforeUpdate = roomUserBrokerChatListRepository.findAll().size();
        roomUserBrokerChatList.setId(count.incrementAndGet());

        // Create the RoomUserBrokerChatList
        RoomUserBrokerChatListDTO roomUserBrokerChatListDTO = roomUserBrokerChatListMapper.toDto(roomUserBrokerChatList);

        // If the entity doesn't have an ID, it will throw BadRequestAlertException
        restRoomUserBrokerChatListMockMvc
            .perform(
                patch(ENTITY_API_URL_ID, roomUserBrokerChatListDTO.getId())
                    .contentType("application/merge-patch+json")
                    .content(TestUtil.convertObjectToJsonBytes(roomUserBrokerChatListDTO))
            )
            .andExpect(status().isBadRequest());

        // Validate the RoomUserBrokerChatList in the database
        List<RoomUserBrokerChatList> roomUserBrokerChatListList = roomUserBrokerChatListRepository.findAll();
        assertThat(roomUserBrokerChatListList).hasSize(databaseSizeBeforeUpdate);
    }

    @Test
    @Transactional
    void patchWithIdMismatchRoomUserBrokerChatList() throws Exception {
        int databaseSizeBeforeUpdate = roomUserBrokerChatListRepository.findAll().size();
        roomUserBrokerChatList.setId(count.incrementAndGet());

        // Create the RoomUserBrokerChatList
        RoomUserBrokerChatListDTO roomUserBrokerChatListDTO = roomUserBrokerChatListMapper.toDto(roomUserBrokerChatList);

        // If url ID doesn't match entity ID, it will throw BadRequestAlertException
        restRoomUserBrokerChatListMockMvc
            .perform(
                patch(ENTITY_API_URL_ID, count.incrementAndGet())
                    .contentType("application/merge-patch+json")
                    .content(TestUtil.convertObjectToJsonBytes(roomUserBrokerChatListDTO))
            )
            .andExpect(status().isBadRequest());

        // Validate the RoomUserBrokerChatList in the database
        List<RoomUserBrokerChatList> roomUserBrokerChatListList = roomUserBrokerChatListRepository.findAll();
        assertThat(roomUserBrokerChatListList).hasSize(databaseSizeBeforeUpdate);
    }

    @Test
    @Transactional
    void patchWithMissingIdPathParamRoomUserBrokerChatList() throws Exception {
        int databaseSizeBeforeUpdate = roomUserBrokerChatListRepository.findAll().size();
        roomUserBrokerChatList.setId(count.incrementAndGet());

        // Create the RoomUserBrokerChatList
        RoomUserBrokerChatListDTO roomUserBrokerChatListDTO = roomUserBrokerChatListMapper.toDto(roomUserBrokerChatList);

        // If url ID doesn't match entity ID, it will throw BadRequestAlertException
        restRoomUserBrokerChatListMockMvc
            .perform(
                patch(ENTITY_API_URL)
                    .contentType("application/merge-patch+json")
                    .content(TestUtil.convertObjectToJsonBytes(roomUserBrokerChatListDTO))
            )
            .andExpect(status().isMethodNotAllowed());

        // Validate the RoomUserBrokerChatList in the database
        List<RoomUserBrokerChatList> roomUserBrokerChatListList = roomUserBrokerChatListRepository.findAll();
        assertThat(roomUserBrokerChatListList).hasSize(databaseSizeBeforeUpdate);
    }

    @Test
    @Transactional
    void deleteRoomUserBrokerChatList() throws Exception {
        // Initialize the database
        roomUserBrokerChatListRepository.saveAndFlush(roomUserBrokerChatList);

        int databaseSizeBeforeDelete = roomUserBrokerChatListRepository.findAll().size();

        // Delete the roomUserBrokerChatList
        restRoomUserBrokerChatListMockMvc
            .perform(delete(ENTITY_API_URL_ID, roomUserBrokerChatList.getId()).accept(MediaType.APPLICATION_JSON))
            .andExpect(status().isNoContent());

        // Validate the database contains one less item
        List<RoomUserBrokerChatList> roomUserBrokerChatListList = roomUserBrokerChatListRepository.findAll();
        assertThat(roomUserBrokerChatListList).hasSize(databaseSizeBeforeDelete - 1);
    }
}
